//
//  FileMessageView.swift
//  swifttest1
//
//  Created by kologe on 2024/9/30.
//

import SwiftUI

struct FileMessageView: View {
    @State var remoteHost:String = ""
    @Binding var isShow:Bool
    @State var filepath:String = "选择文件"
    
    var body: some View {
        VStack{
            selectFD(fileName: $filepath)
        }
        Button {
            sendMessage()
        } label: {
            Label("发送文件", systemImage: "")
                .foregroundColor(.white)
                .padding(EdgeInsets(top: 4, leading: 4, bottom: 4, trailing: 4))
                .background(
                    RoundedRectangle(cornerRadius: 10)
                        .foregroundColor(.blue)
                )
                .compositingGroup()
                .shadow(radius: 5,x:0,y:3)
                .contentShape(Rectangle())
        }
        .nomalStyle()
    }
    func sendMessage(){
        if filepath.isEmpty || filepath == "选择文件"{
            return
        }
        TCPClientManager.shared.sendFileMsg(ip: remoteHost, filePath: filepath)
        isShow = false
        
    }
}

#Preview {
    FileMessageView(isShow: .constant(false))
}
